package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.DateTypeEnum;
import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * 所有字段枚举
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/30 11:02
 * @since v1.0
 */
@Getter
public enum SelectBatchEnum {
    // 模板设置界面展示字段
    BATCH("batch", "enum.selectBatch.attrName.batch", "batch", FieldTypeEnum.TEXT.getType(), 1, 0, null),
    PRODUCE_DATE("produceDate", "enum.selectBatch.attrName.produceDate", "produceDate", FieldTypeEnum.DATETIME.getType(), 1, 0, DateTypeEnum.YMD.getAlias()),
    EXPIRE_DATE("expireDate", "enum.selectBatch.attrName.expireDate", "expireDate", FieldTypeEnum.DATETIME.getType(), 1, 0, DateTypeEnum.YMD.getAlias()),
    BASE_UNIT("baseUnit", "enum.selectBatch.attrName.baseUnit", "unit", FieldTypeEnum.TEXT.getType(), 1, 0, null),
    STOCK("stock", "enum.selectBatch.attrName.stock", "stock", FieldTypeEnum.NUM.getType(), 1, 0, null),
    THIS_OUT_STOCK("thisOutStock", "enum.selectBatch.attrName.thisOutStock", "thisOutStock", FieldTypeEnum.NUM.getType(), 1, 0, null),
    ;


    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;
    /**
     * 日期类型
     */
    private String dateType;

    SelectBatchEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer visible, Integer required, String dateType) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.visible = visible;
        this.required = required;
        this.dateType = dateType;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }

    public static List<SelectBatchEnum> noShelfEnumList = Arrays.asList(SelectBatchEnum.PRODUCE_DATE, SelectBatchEnum.EXPIRE_DATE);
}
